        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>Transform class / box2d_console Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d_console" data-type="Transform">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d_console.html">box2d_console</a> &rsaquo; <a href="../box2d_console/Transform.html">Transform</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>Transform</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<p>A transform is a translation and a rotation. It represents the position and
orientation of rigid frames.</p>
<pre class="source">
class Transform {
  /** The translation caused by a transform. */
  final Vector position;

  /** A matrix representing a rotation. */
  final Matrix22 rotation;

  /**
   * Constructs a new transform with a vector at the origin and no rotation.
   */
  Transform() : position = new Vector(), rotation = new Matrix22();

  /**
   * Constructs a new transform equal to the given transform.
   */
  Transform.copy(Transform other)
      : position = new Vector.copy(other.position),
        rotation = new Matrix22.copy(other.rotation);

  bool operator ==(other) {
    return position == other.position &amp;&amp; rotation == other.rotation;
  }

  /**
   * Sets this transform with the given position and rotation.
   */
  void setFromPositionAndRotation(Vector argPosition, Matrix22 argRotation) {
    position.setFrom(argPosition);
    rotation.setFrom(argRotation);
  }

  /**
   * Sets this transform equal to the given transform.
   */
  void setFrom(Transform other) {
    position.setFrom(other.position);
    rotation.setFrom(other.rotation);
  }

  /**
   * Multiply the given transform and given vector and return a new Vector with
   * the result.
   */
  static Vector mul(Transform T, Vector v) {
    return new Vector(T.position.x + T.rotation.col1.x * v.x +
        T.rotation.col2.x * v.y, T.position.y + T.rotation.col1.y * v.x +
        T.rotation.col2.y * v.y);
  }

  /**
   * Multiplies the given transform and the given vector and places the result
   * in the given out parameter.
   */
  static void mulToOut(Transform transform, Vector vector, Vector out) {
    assert(out != null);
    num tempY = transform.position.y + transform.rotation.col1.y *
        vector.x + transform.rotation.col2.y * vector.y;
    out.x = transform.position.x + transform.rotation.col1.x * vector.x +
        transform.rotation.col2.x * vector.y;
    out.y = tempY;
  }

  static void mulTransToOut(Transform T, Vector v, Vector out) {
    num v1x = v.x - T.position.x;
    num v1y = v.y - T.position.y;
    Vector b = T.rotation.col1;
    Vector b1 = T.rotation.col2;
    num tempy = v1x * b1.x + v1y * b1.y;
    out.x = v1x * b.x + v1y * b.y;
    out.y = tempy;
  }
}
</pre>
</div>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="Transform">
<button class="show-code">Code</button>
new <strong>Transform</strong>() <a class="anchor-link" href="#Transform"
              title="Permalink to Transform.Transform">#</a></h4>
<div class="doc">
<p>Constructs a new transform with a vector at the origin and no rotation.</p>
<pre class="source">
Transform() : position = new Vector(), rotation = new Matrix22();
</pre>
</div>
</div>
<div class="method"><h4 id="Transform.copy">
<button class="show-code">Code</button>
new <strong>Transform.copy</strong>(<a href="../box2d_console/Transform.html">Transform</a> other) <a class="anchor-link" href="#Transform.copy"
              title="Permalink to Transform.Transform.copy">#</a></h4>
<div class="doc">
<p>Constructs a new transform equal to the given transform.</p>
<pre class="source">
Transform.copy(Transform other)
    : position = new Vector.copy(other.position),
      rotation = new Matrix22.copy(other.rotation);
</pre>
</div>
</div>
</div>
<div>
<h3>Static Methods</h3>
<div class="method"><h4 id="mul">
<button class="show-code">Code</button>
<a href="../box2d_console/Vector.html">Vector</a> <strong>mul</strong>(<a href="../box2d_console/Transform.html">Transform</a> T, <a href="../box2d_console/Vector.html">Vector</a> v) <a class="anchor-link" href="#mul"
              title="Permalink to Transform.mul">#</a></h4>
<div class="doc">
<p>Multiply the given transform and given vector and return a new Vector with
the result.</p>
<pre class="source">
static Vector mul(Transform T, Vector v) {
  return new Vector(T.position.x + T.rotation.col1.x * v.x +
      T.rotation.col2.x * v.y, T.position.y + T.rotation.col1.y * v.x +
      T.rotation.col2.y * v.y);
}
</pre>
</div>
</div>
<div class="method"><h4 id="mulToOut">
<button class="show-code">Code</button>
void <strong>mulToOut</strong>(<a href="../box2d_console/Transform.html">Transform</a> transform, <a href="../box2d_console/Vector.html">Vector</a> vector, <a href="../box2d_console/Vector.html">Vector</a> out) <a class="anchor-link" href="#mulToOut"
              title="Permalink to Transform.mulToOut">#</a></h4>
<div class="doc">
<p>Multiplies the given transform and the given vector and places the result
in the given out parameter.</p>
<pre class="source">
static void mulToOut(Transform transform, Vector vector, Vector out) {
  assert(out != null);
  num tempY = transform.position.y + transform.rotation.col1.y *
      vector.x + transform.rotation.col2.y * vector.y;
  out.x = transform.position.x + transform.rotation.col1.x * vector.x +
      transform.rotation.col2.x * vector.y;
  out.y = tempY;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mulTransToOut">
<button class="show-code">Code</button>
void <strong>mulTransToOut</strong>(<a href="../box2d_console/Transform.html">Transform</a> T, <a href="../box2d_console/Vector.html">Vector</a> v, <a href="../box2d_console/Vector.html">Vector</a> out) <a class="anchor-link" href="#mulTransToOut"
              title="Permalink to Transform.mulTransToOut">#</a></h4>
<div class="doc">
<pre class="source">
static void mulTransToOut(Transform T, Vector v, Vector out) {
  num v1x = v.x - T.position.x;
  num v1y = v.y - T.position.y;
  Vector b = T.rotation.col1;
  Vector b1 = T.rotation.col2;
  num tempy = v1x * b1.x + v1y * b1.y;
  out.x = v1x * b.x + v1y * b.y;
  out.y = tempy;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="position">
<button class="show-code">Code</button>
final <a href="../box2d_console/Vector.html">Vector</a>         <strong>position</strong> <a class="anchor-link"
            href="#position"
            title="Permalink to Transform.position">#</a>
        </h4>
        <div class="doc">
<p>The translation caused by a transform.</p>
<pre class="source">
final Vector position;
</pre>
</div>
</div>
<div class="field"><h4 id="rotation">
<button class="show-code">Code</button>
final <a href="../box2d_console/Matrix22.html">Matrix22</a>         <strong>rotation</strong> <a class="anchor-link"
            href="#rotation"
            title="Permalink to Transform.rotation">#</a>
        </h4>
        <div class="doc">
<p>A matrix representing a rotation.</p>
<pre class="source">
final Matrix22 rotation;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="runtimeType">
<button class="show-code">Code</button>
final Type         <strong>runtimeType</strong> <a class="anchor-link"
            href="#runtimeType"
            title="Permalink to Transform.runtimeType">#</a>
        </h4>
        <div class="inherited-from">inherited from Object </div><div class="doc">
<p>A representation of the runtime type of the object.</p>
<pre class="source">
external Type get runtimeType;
</pre>
</div>
</div>
</div>
<div>
<h3>Operators</h3>
<div class="method"><h4 id="==">
<button class="show-code">Code</button>
bool <strong>operator ==</strong>(other) <a class="anchor-link" href="#=="
              title="Permalink to Transform.operator ==">#</a></h4>
<div class="doc">
<div class="inherited">
<p>The equality operator.</p>
<p>The default behavior for all <code>Object</code>s is to return true if and
only if <code>this</code> and 
<span class="param">other</span> are the same object.</p>
<p>If a subclass overrides the equality operator it should override
the <code>hashCode</code> method as well to maintain consistency.</p>
<div class="docs-inherited-from">docs inherited from Object </div></div>
<pre class="source">
bool operator ==(other) {
  return position == other.position &amp;&amp; rotation == other.rotation;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method inherited"><h4 id="hashCode">
<button class="show-code">Code</button>
int <strong>hashCode</strong>() <a class="anchor-link" href="#hashCode"
              title="Permalink to Transform.hashCode">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Get a hash code for this object.</p>
<p>All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator <code>==</code>. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.</p>
<p>If a subclass overrides <code>hashCode</code> it should override the
equality operator as well to maintain consistency.</p>
<pre class="source">
external int hashCode();
</pre>
</div>
</div>
<div class="method inherited"><h4 id="noSuchMethod">
<button class="show-code">Code</button>
<strong>noSuchMethod</strong>(String name, List args) <a class="anchor-link" href="#noSuchMethod"
              title="Permalink to Transform.noSuchMethod">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p><code>noSuchMethod</code> is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to <code>noSuchMethod</code>. If <code>noSuchMethod</code>
returns a value, that value becomes the result of the original
invocation.</p>
<p>The default behavior of <code>noSuchMethod</code> is to throw a
<code>noSuchMethodError</code>.</p>
<pre class="source">
external Dynamic noSuchMethod(String name, List args);
</pre>
</div>
</div>
<div class="method inherited"><h4 id="Object">
<button class="show-code">Code</button>
const <strong>Object</strong>() <a class="anchor-link" href="#Object"
              title="Permalink to Transform.Object">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Creates a new <code>Object</code> instance.</p>
<p><code>Object</code> instances have no meaningful state, and are only useful
through their identity. An <code>Object</code> instance is equal to itself
only.</p>
<pre class="source">
const Object();
</pre>
</div>
</div>
<div class="method"><h4 id="setFrom">
<button class="show-code">Code</button>
void <strong>setFrom</strong>(<a href="../box2d_console/Transform.html">Transform</a> other) <a class="anchor-link" href="#setFrom"
              title="Permalink to Transform.setFrom">#</a></h4>
<div class="doc">
<p>Sets this transform equal to the given transform.</p>
<pre class="source">
void setFrom(Transform other) {
  position.setFrom(other.position);
  rotation.setFrom(other.rotation);
}
</pre>
</div>
</div>
<div class="method"><h4 id="setFromPositionAndRotation">
<button class="show-code">Code</button>
void <strong>setFromPositionAndRotation</strong>(<a href="../box2d_console/Vector.html">Vector</a> argPosition, <a href="../box2d_console/Matrix22.html">Matrix22</a> argRotation) <a class="anchor-link" href="#setFromPositionAndRotation"
              title="Permalink to Transform.setFromPositionAndRotation">#</a></h4>
<div class="doc">
<p>Sets this transform with the given position and rotation.</p>
<pre class="source">
void setFromPositionAndRotation(Vector argPosition, Matrix22 argRotation) {
  position.setFrom(argPosition);
  rotation.setFrom(argRotation);
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="toString">
<button class="show-code">Code</button>
String <strong>toString</strong>() <a class="anchor-link" href="#toString"
              title="Permalink to Transform.toString">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Returns a string representation of this object.</p>
<pre class="source">
external String toString();
</pre>
</div>
</div>
<div class="method"><h4 id="Transform">
<button class="show-code">Code</button>
new <strong>Transform</strong>() <a class="anchor-link" href="#Transform"
              title="Permalink to Transform.Transform">#</a></h4>
<div class="doc">
<p>Constructs a new transform with a vector at the origin and no rotation.</p>
<pre class="source">
Transform() : position = new Vector(), rotation = new Matrix22();
</pre>
</div>
</div>
<div class="method"><h4 id="Transform.copy">
<button class="show-code">Code</button>
new <strong>Transform.copy</strong>(<a href="../box2d_console/Transform.html">Transform</a> other) <a class="anchor-link" href="#Transform.copy"
              title="Permalink to Transform.Transform.copy">#</a></h4>
<div class="doc">
<p>Constructs a new transform equal to the given transform.</p>
<pre class="source">
Transform.copy(Transform other)
    : position = new Vector.copy(other.position),
      rotation = new Matrix22.copy(other.rotation);
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
